Stock displays. Code cribbed from this notebook by Thomas Wiecki.


In [ ]:
stock = 'MSFT'   # Display names are stored in notebook metadata
days_back = 600

In [ ]:
import datetime

import pandas as pd
import pandas_datareader.data as webdata
from matplotlib import pyplot as plt
%matplotlib inline

In [ ]:
now = datetime.date.today()
start = now - datetime.timedelta(days=days_back)
df = webdata.get_data_yahoo(stock, start=start, end=now)['prices']

In [ ]:
df

In [ ]:
close_px = df['Adj Close']
mavg = close_px.rolling(window=30, center=False).mean()

In [ ]:
close_px.plot(label=stock)
mavg.plot(label='mavg')
plt.legend()